Aim of Analysis

The aim of the following analysis is to determine if teams that take shots from Zone 2 score more points than teams that do not.

Step 1. Load The Required Packages

Before analysing the data the following packages will need to be loaded;

here - constructs a path to the projects data file

tidyverse - a set of packages designed to work in together, packages needed within tidyverse include dtplyr and ggplot2

knitr - provides a general purpose tool for generating reports

plotly - creates interactive web graphics in conjunction with ggplot2

viridis - colours graphs in a readable format for color blind individuals

# Load required packages
library(here)
library(tidyverse)
library(knitr)
library(plotly)
library(viridis)
library(flexdashboard)

Step 2. Load the Data

Load the data by using the read.csv function and the here package.

# Load in the data
Dataset3_Assessment3 <- read.csv(here("Data/Dataset3_Assessment3.csv"))

Step 3. Run Summary Data

SummaryData_All <- Dataset3_Assessment3 %>%
group_by(Team, Statistic) %>%
summarise(Min = min(Total),
Max = max(Total),
Mean = mean(Total),
SD = sd(Total),
Sum = sum(Total))

Step 4. Isolate Attempts from Zone 2

SummaryData_attempt_from_zone2 <-
filter(SummaryData_All, Statistic == "attempt_from_zone2")

Step 5. Plot Attempts from Zone 2

PlotAttempts <- ggplot(SummaryData_attempt_from_zone2, aes(x = Statistic, y = Sum)) +
  geom_jitter(aes(colour = Team)) +
  scale_colour_viridis_d() +
  geom_boxplot(alpha = 0.3) +
  xlab("Attempts from Zone 2") +
  ggtitle("Figure 1")+
  theme_classic()

#make the plot interactive
ggplotly(PlotAttempts)